grep ':1;' <global.h  | sed '
s/.*unsigned //
s/:1.*//' |awk '
BEGIN{
bit = 0;
printf("#include \"pai.h\"\n");
printf("#include \"global.h\"\n");
printf("#include \"result.h\"\n");
printf("\nresult_cvt_to_int(yp, iy) result_t *yp; int *iy; {\n\n");
printf("	iy[0] = 0;\n");
printf("	iy[1] = 0;\n");
printf("	iy[2] = 0;\n");
printf("	iy[3] = 0;\n\n");
}
{
printf("	if (yp->%s)		Y_SET(iy,%d);\n",$1,bit);
bit++;
}
END{
printf("}\n\n");
}' >cvt.c

grep ':1;' <global.h  | sed '
s/.*unsigned //
s/:1.*//' |awk '
BEGIN{
bit = 0;
printf("\nresult_cvt_from_int(yp, iy) result_t *yp; int *iy; {\n\n");
}
{
printf("	yp->%s			= Y_GET(iy,%d);\n",$1,bit);
bit++;
}
END{
printf("}\n\n");
}' >>cvt.c

grep ':1;' <global.h  | sed '
s/.*unsigned //
s/:1.*//' |perl -e '
open(F1,"mk_cvt.db");
while (<F1>) {
        chop;
	if (/^([^ \t]+)[ \t]+([^ \t])+[ \t]+([^ \t].*)$/) {
		$name{"$1"} = $3;
	}
}
close(F1);

while(<STDIN>) {
        chop;
        printf("%s\n",$name{"$_"});
}
' | awk '
BEGIN{
printf("\n#ifdef ASCII_MESSAGE\n");
printf("\nchar *result_str[Y_MAX] = {\n");
}
{
printf("	\"%s\",\n",$0);
bit++;
}
END{
printf("};\n");
printf("#else\n");
}' >>cvt.c


grep ':1;' <global.h  | sed '
s/.*unsigned //
s/:1.*//' |perl -e '
open(F1,"mk_cvt.db");
while (<F1>) {
        chop;
        @line = split("[ \t]+");
        $name{"$line[0]"} = "$line[1]";
}
close(F1);

while(<STDIN>) {
        chop;
        printf("\t%s\n",$name{"$_"});
}
' | awk '
BEGIN{
printf("\nchar *result_str[Y_MAX] = {\n");
}
{
printf("	\"%s\",\n",$1);
bit++;
}
END{
printf("};\n");
printf("#endif\n");
}' >>cvt.c
